from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
import django.contrib.auth.views

import shop.views

admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
    (r'^threadedcomments/', include('threadedcomments.urls')),

    (r'^$', shop.views.product.list, {'category_id': None}),
    (r'^category/(?P<category_id>\d+)$', shop.views.product.list),
    (r'^product/(?P<product_id>\d+)$', shop.views.product.detail),
    (r'^search$', shop.views.product.search),
    (r'^login/$', shop.views.auth.login, {'template_name' : 'login.html'}),
    (r'^logout$', shop.views.auth.logout),
    (r'^register', shop.views.auth.register),
    (r'^account', shop.views.auth.account),
    (r'^cart$', shop.views.cart.show),
    (r'^cart/add/(?P<product_id>\d+)$', shop.views.cart.add),
    (r'^cart/remove/(?P<product_id>\d+)$', shop.views.cart.remove),
    (r'^cart/update/(?P<product_id>\d+)$', shop.views.cart.update),
    (r'^cart/clear$', shop.views.cart.clear),
    (r'^checkout$', shop.views.checkout.show),
    (r'^checkout_confirmed$', shop.views.checkout.create_order),
    (r'^checkout/(?P<order_id>\d+)$', shop.views.checkout.show_payment),
    (r'^checkout/cancel$', shop.views.checkout.cancel),
    (r'^checkout/callback/(?P<result>\w+)$', shop.views.checkout.callback),
    (r'^rate/(?P<product_id>\d+)/(?P<stars>\d+)$', shop.views.rating.ajax_rate),
    (r'^rate$', shop.views.rating.form_rate),
    (r'^orders$', shop.views.orders.show_orders),
    (r'^order/(?P<order_id>\d+)$', shop.views.orders.show_completed_order)
)

if settings.DEBUG:
    urlpatterns += patterns('',
            (r'^static/(?P<path>.*)$', 'django.views.static.serve', {
                'document_root': settings.MEDIA_ROOT}),
    )

